<?php if(isset($tipo) && $tipo == 1){
	$total_trabalhos = $this->requestAction('/trabalhos/total_por_revisor');
	$total_trabalhos_por_categoria = $this->requestAction('/trabalhos/total_por_revisor_por_categoria');
	foreach($total_trabalhos_por_categoria as $user_id=>$trabalhos_do_revisor){ ?>
		<!-- Modal -->
		<div id="myModal-<?php echo $user_id;?>" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-header">
		<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
		<h3 id="myModalLabel"><?php echo __('Trabalhos Por Categoria');?></h3>
		</div>
		<div class="modal-body">
			<table class="table">
			<?php foreach($trabalhos_do_revisor as $categoria=>$total){?>
				<tr>
				<td><?php echo $categoria.'</td><td>'.$total;?></td>
				</tr>
			<?php }?>
			</table>
		</div>
		<div class="modal-footer">
		<button class="btn" data-dismiss="modal" aria-hidden="true"><?php echo __('Close');?></button>
		</div>
		</div>
		<?php }?>
	<?php } ?>
<script type="text/javascript">
jQuery(function(){
	 $(".btn").tooltip();
});
</script>
<?php if(isset($tipo)){?>
<h2><?php echo __('Usuários ').$tipos[$submenu][$tipo];?></h2>
<?php }else{?>
<h2><?php echo __('Usuários ');?></h2>
<?php }?>
	<?php echo $this->element('menu/index_usuarios_recepcionista');?>
	<br>
	<?php echo $this->Form->create(false, array('url'=>$this->Html->url(array('controller'=>'usuarios', 'action'=>'index_recepcionista', $submenu, $tipo), true))); ?>
	<div class="input-append">
		<?php echo $this->Form->input('search', array('div'=>false, 'label'=>false, 'placeholder'=>__('Busca por Nome, E-mail e Login')));?>
		<?php echo $this->Form->submit(__('Buscar'), array('div'=>false, 'class'=>'btn'))?>
		<?php echo $this->Html->link(__('Limpar busca'), $this->Html->url(array('controller'=>'usuarios', 'action'=>'index', $submenu, $tipo), true), array('class'=>'btn'))?>
	</div>
	<?php echo $this->Form->end();?>
	<table cellpadding="0" cellspacing="0" class="table table-striped table-bordered table-hover">
	<thead>
	<tr>
		<th><?php echo $this->Paginator->sort('nome', __('Nome')); ?></th>
		<th><?php echo 'Estado'; ?></th>
		<th><?php echo $this->Paginator->sort('nome', __('Categoria')); ?></th>
		<th><?php echo $this->Paginator->sort('nome', __('Sócio')); ?></th>
		<th><?php echo $this->Paginator->sort('nome', __('Valor')); ?></th>
		<th class="actions"></th>
	</tr>
	</thead><?php //pr($usuarios);?>
	<?php foreach ($usuarios as $usuario): ?>
	<tbody>
	<?php // TODO ATUALIZAR AQUI QUANDO ALTERAR PARA VÀRIOS GATEWAYS ?>
	<tr>
		<td><?php echo h($usuario['Usuario']['nome']); ?>&nbsp;</td>
		<td><?php echo h($usuario['Endereco']['estado']); ?>&nbsp;</td>
		<td><?php echo h($usuario['Especializacao']['nome']); ?>&nbsp;</td>
		<td><?php echo h($usuario['Associacao']['nome']); ?>&nbsp;</td>
		<td>R$ <?php echo h($usuario['Pagamento']['valor_total']); ?>&nbsp;</td>
		<td class="actions">
			<div class="btn-toolbar">
			  <div class="btn-group">
			  	<?php echo $this->Html->link('<i class="icon-user"></i>', array('action' => 'view', $usuario['Usuario']['id']), array('class'=>'btn', 'escape'=>false, 'title'=>__('Ver'))); ?>
			  	<?php if ($usuario['Usuario']['presente'] != 1) {echo $this->Html->link('<i class="icon-ok"></i>', array('action' => 'marca_presenca', $usuario['Usuario']['id']), array('class'=>'btn', 'escape'=>false, 'title'=>__('Marcar Presença')));}
			  	else {echo $this->Html->link('<i class="icon-remove"></i>', array('action' => 'marca_presenca', $usuario['Usuario']['id']), array('class'=>'btn', 'escape'=>false, 'title'=>__('Cancelar Presença')));} ?>
			    <?php if($editavel){
			    	echo $this->Html->link('<i class="icon-edit"></i>', array('action' => 'edit', $usuario['Usuario']['id']), array('class'=>'btn', 'title'=>__('Alterar'), 'escape'=>false)); 
			    	if(empty($usuario['Pagamento']['id'])) echo $this->Html->link('<strong>$</strong>', array('controller'=>'pagamentos', 'action' => 'marcar_como_pago', $usuario['Usuario']['id']), array('class'=>'btn btn-success', 'title'=>__('Marcar como pago'), 'escape'=>false));
				}?>
			    <?php if($editavel && isset($tipo)) echo $this->Form->postLink('<i class="icon-trash"></i>', array('action' => 'delete', $usuario['Usuario']['id']), array('class'=>'btn', 'escape'=>false, 'title'=>__('Excluir usuário')), __('Tem certeza que deseja escluir o usuário %s?', $usuario['Login']['login'])); ?>
			    <?php if(isset($tipo) && $tipo == 3 ) echo $this->Form->postLink('<i class="icon-remove"></i>', array('controller' => 'pagamentos','action' => 'delete', $usuario['Pagamento']['id']), 
			    								 array('class'=>'btn', 'escape'=>false, 'title'=>__('Cancelar inscrição')), 
			    								 __('Deseja realmente remover a inscrição de %s?', $usuario['Login']['login'])); ?>
			  </div>
			</div>
		</td>
	</tr>
<?php endforeach; ?>
	</tbody>
</table>
<p class="text-info">
<?php
echo $this->Paginator->counter(array(
'format' => __('Página {:page} de {:pages}, total de {:count} registros')
));
?>	</p>
<div class="pagination pagination-centered">
	<ul>
		<?php echo $this->Paginator->prev(
			'< '.__('Anterior'),
			array('tag' => 'li', 'class' => 'prev'),
			'<a>< '.__('Anterior').'</a>',
			array('tag' => 'li', 'escape' => false, 'class' => 'prev disabled')
		);?>
		<?php echo $this->Paginator->numbers(array('separator' => '', 'tag'=>'li', 'currentTag'=>'a', 'currentClass'=>'active')); ?>
		<?php echo $this->Paginator->next(
			__('Próximo'). ' >',
			array('tag' => 'li', 'class' => 'prev'),
			'<a>'.__('Próximo').' ></a>',
			array('tag' => 'li', 'escape' => false, 'class' => 'prev disabled')
		);?>
	</ul>
</div>